package com.party.core.service.commune.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.commune.CRouteReadDao;
import com.party.core.dao.write.commune.CRouteWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.commune.CRoute;
import com.party.core.service.commune.ICRouteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 路线管理服务实现
 * @Date: 2019/10/22 15:32
 */
@Service
public class CRouteService implements ICRouteService {

    @Autowired
    private CRouteReadDao cRouteDao;
    @Autowired
    private CRouteWriteDao cRouteWriteDao;

    @Override
    public String insert(CRoute cRoute) {
        BaseModel.preInsert(cRoute);
        boolean result = this.cRouteWriteDao.insert(cRoute);
        if (result)
        {
            return cRoute.getId();
        }
        return null;
    }

    @Override
    public boolean update(CRoute cRoute) {
        cRoute.setUpdateDate(new Date());
        return this.cRouteWriteDao.update(cRoute);
    }

    @Override
    public boolean deleteLogic(String id) {
        return this.cRouteWriteDao.deleteLogic(id);
    }

    @Override
    public boolean delete(String id) {
        return this.cRouteWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return this.cRouteWriteDao.batchDeleteLogic(ids);
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return this.cRouteWriteDao.batchDelete(ids);
    }

    @Override
    public CRoute get(String id) {
        return this.cRouteDao.get(id);
    }

    @Override
    public List<CRoute> listPage(CRoute cRoute, Page page) {
        return this.cRouteDao.listPage(cRoute,page);
    }

    @Override
    public List<CRoute> list(CRoute cRoute) {
        return null;
    }

    @Override
    public List<CRoute> batchList(Set<String> ids, CRoute cRoute, Page page) {
        return null;
    }

    @Override
    public List<CRoute> webPageList(Map<String, Object> params, Page page) {
        return this.cRouteDao.webPageList(params,page);
    }

    @Override
    public List<CRoute> getAllRoute(String partnerId, List<String> orgIds) {
        return this.cRouteDao.getAllRoute(partnerId,orgIds);
    }

    @Override
    public CRoute getRouteByName(String routeName,String partnerId) {
        return this.cRouteDao.getRouteByName(routeName,partnerId);
    }
}
